const path = require('path')

const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')

module.exports = {
    entry: './src/main.js',
    mode: 'development',
    output: {
        filename: '[name].build.js',
        path: path.resolve(__dirname, 'dist'),
    },
    module: {
        rules: [
            {
                test: /\.css|.scss/,
                use: [
                    {loader: 'vue-style-loader'},
                    {loader: 'css-loader'},
                    {
                        loader: 'sass-loader',
                        options: {
                            additionalData: `@import 'src/assets/css/main.scss';`
                          }
                    },
                ]
            },
            {
                test: /\.vue$/,
                loader: 'vue-loader'
            },
            {
                test: /\.(png|svg|jpg|jpeg|gif)$/i,
                type: 'asset/resource'
            }
        ]
    },
    plugins: [
        new VueLoaderPlugin(),
        new HtmlWebpackPlugin({
            template: './public/index.html'
        })
    ],
    devtool: 'inline-source-map',
    devServer: {
        static: './dist'
    },
    optimization: {
        runtimeChunk: 'single'
    },
    resolve: {
        alias: {
            '@': path.join(__dirname, 'src/'),
            'imgs': path.join(__dirname, 'src/assets/imgs/')
        }
    }
}